﻿#include "knowledgebaseplugin.h"
#include "plugins/KnowledgeBase/knowledgebasemainwindow.h"
#include "plugins/KnowledgeBase/knowledgebase.h"

KnowledgeBasePlugin::KnowledgeBasePlugin(QObject *parent) :
    QObject(parent)
{

}


int KnowledgeBasePlugin::initPlugin(QMainWindow* mainWin,QSplitter* leftSplitter
                                    ,QWidget* leftBottombar
                                    ,QSplitter* mainSplitter)
{
    KnowledgebaseMainWindow* knowledgebaseMnWnd = new KnowledgebaseMainWindow();
    mainSplitter->insertWidget(1,knowledgebaseMnWnd);

    KnowledgeBase* knowledge = new KnowledgeBase();
    leftSplitter->insertWidget(0,knowledge);

    // 连接信号
    connect(knowledge,SIGNAL(userSelectedPath(QString)),knowledgebaseMnWnd,SLOT(showArticlesListByDir(QString)));

    // mainWin
    // create actions
    newArticle = new QAction(QIcon(":/knowledgebase/images/Tips.png"), tr("&New Article"),
                               mainWin);
    newArticle->setShortcuts(QKeySequence::New);
    newArticle->setStatusTip(tr("Create a new article"));
    connect(newArticle, SIGNAL(triggered()), knowledgebaseMnWnd, SLOT(newArticle()));

    // create menu
    articleMenu = mainWin->menuBar()->addMenu(tr("&Article"));
    articleMenu->addAction(newArticle);
    articleMenu->addSeparator();
    //fileMenu->addAction(quitAct);

    // create boolbar
    articleToolBar = mainWin->addToolBar(tr("Article"));
    articleToolBar->addAction(newArticle);
    // create

    return 0;
}
